#ifndef MY_TIMER_H
#define MY_TIMER_H

typedef int timer_expiry(void *user_data);

struct timer
{
    struct timer *prev;
    struct timer *next;

    struct timeval expire_time;

    void *user_data;           /**< callback arg               */
    void *queue;       /* pointer point back to queue  */
};

typedef struct timer_queue
{
    struct timer  *timer_header;
    struct timer  *timer_tail;
    timer_expiry *cb;
    time_t interval;
    pthread_cond_t *mycond;
    pthread_mutex_t *mymutex;
} timer_queue;

int
timer_init(timer_queue *queue, timer_expiry *cb, time_t interval, pthread_mutex_t *mymutex);
struct timer *
add_timer(timer_queue *queue, void *user_data);
int
del_timer(struct timer *t);
void *
timer_thread(void *arg);


#endif /*MY_TIMER_H*/
